<?php

/**
 * Mp filter form base class.
 *
 * @package    explications_informatiques
 * @subpackage filter
 * @author     Guimezanes Cyrille
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseMpFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_auteur'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile'), 'add_empty' => true)),
      'id_destinataire' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile_2'), 'add_empty' => true)),
      'sujet'           => new sfWidgetFormFilterInput(),
      'message'         => new sfWidgetFormFilterInput(),
      'date'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'lu'              => new sfWidgetFormFilterInput(),
      'suppr_author'    => new sfWidgetFormFilterInput(),
      'suppr_desti'     => new sfWidgetFormFilterInput(),
      'topic'           => new sfWidgetFormFilterInput(),
      'spam'            => new sfWidgetFormFilterInput(),
      'online'          => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'id_auteur'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('SfGuardUserProfile'), 'column' => 'id')),
      'id_destinataire' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('SfGuardUserProfile_2'), 'column' => 'id')),
      'sujet'           => new sfValidatorPass(array('required' => false)),
      'message'         => new sfValidatorPass(array('required' => false)),
      'date'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'lu'              => new sfValidatorPass(array('required' => false)),
      'suppr_author'    => new sfValidatorPass(array('required' => false)),
      'suppr_desti'     => new sfValidatorPass(array('required' => false)),
      'topic'           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'spam'            => new sfValidatorPass(array('required' => false)),
      'online'          => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('mp_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Mp';
  }

  public function getFields()
  {
    return array(
      'idmp'            => 'Number',
      'id_auteur'       => 'ForeignKey',
      'id_destinataire' => 'ForeignKey',
      'sujet'           => 'Text',
      'message'         => 'Text',
      'date'            => 'Date',
      'lu'              => 'Text',
      'suppr_author'    => 'Text',
      'suppr_desti'     => 'Text',
      'topic'           => 'Number',
      'spam'            => 'Text',
      'online'          => 'Text',
    );
  }
}
